package com.brillilab.service.core.method;

import com.brillilab.common.entity.PageVo;
import com.brillilab.domain.enums.common.BoolEnum;
import com.brillilab.domain.pa.method.MethodListPa;
import com.brillilab.domain.po.method.Method;
import com.brillilab.domain.vo.method.*;
import com.brillilab.domain.vo.user.UserInfoVo;

import java.util.List;

/**
 * @author wuzhiyu
 * @Title: IMethodService
 * @ProjectName brill_lab
 * @Description: TODO
 * @date 2019/2/2113:13
 */

public interface IMethodService {
    /**
     * @return boolean
     * @Description: 保存并更新initMethodId字段
     * @Params: [method]
     * @author wuzhiyu
     * @date 2019/2/26 17:29
     */
    boolean saveMethodAndUpdateInitId(Method method);

    /**
     * @return com.brillilab.domain.po.method.Method
     * @Description: 获取method
     * @Params: [id]
     * @author wuzhiyu
     * @date 2019/2/26 17:29
     */
    Method getById(Long id);

    /**
     * @return com.brillilab.domain.vo.method.ReferMethodListItem
     * @Description: 通过类型id获取一个推荐的参考方法
     * @Params: [thirdTypeId]
     * @author wuzhiyu
     * @date 2019/2/26 17:29
     */
    ReferMethodListItem getReferRecommondOneByThirdTypeId(Long thirdTypeId);

    /**
     * @return java.util.List<com.brillilab.domain.po.method.Method>
     * @Description: 搜索
     * @Params: [thridTypeId, name]
     * @author wuzhiyu
     * @date 2019/2/26 17:30
     */
    List<Method> getReferMethodListByTypeAndName(Long thridTypeId, String name);

    List<Method> listByNameAndUserId(String methodName, Long userId);

    List<Method> listByTypeIdAndUserId(Long thirdTypeId, Long userId);

    List<Method> listByIdList(List<Long> methodIdList, Long userId);

    boolean save(Method method);

    Integer getCurrentMaxVersion(Long initMethodId);

    List<Method> listByInitMethodId(Long initMethodId, Long userId);

    /**
     * @return com.brillilab.common.entity.PageVo<com.brillilab.domain.po.method.Method>
     * @Description: 获取分页参考方法
     * @Params: [thirdTypeId, name, pageIndex, rows]
     * @author wuzhiyu
     * @date 2019/2/26 18:30
     */
    PageVo<Method> listPagedReferMethod(List<Long> thirdTypeId, String name, Integer pageIndex, Integer rows, boolean iskit);

    boolean update(MethodUpdate methodUpdate, UserInfoVo user);

    Method getByInitMethodIdAndVersion(Long initMethodId, Integer version);

    List<Method> listSameSourceMethod(Long sourceMethodId, Long userId);

    boolean delete(Long initMethodId, Long userId);

    List<Method> listRecommendMethod(Long labId);
    List<Method> listByTypeIdListAndCurrent(List<Long> typeIdList, Long userId);
    boolean saveMethodAndUpdateInitIdAndRecommentId(Method method);

    boolean increaseExportCount(Long methodId);

  List<Method>  getByThirdTypeIdAndMethodNameAndUserId(Long thirdTypeId,String methodName,Long userId);

  List<Method> getSameTypeAndSameSourceMethod(String methodName,Long myThirdType,Long otherSourceMethodId,Long userId);

  List<Method> getMethodListByUserIdAndState(Long userId, BoolEnum isDelete,BoolEnum isCurrent,boolean hasCommonMethod);
    /** ######################## lijian #############################*/

    /**
     * 参考方法统计数据
     */
    ReferMethodStatisticsVo referMethodStatistics();

    /**
     * 方法参考推荐（为你推荐）
     *
     * @param userId
     * @param methodTypeId
     * @return
     */
    List<MethodReferRecommendVo> getMethodReferRecommendList(Long userId, Long methodTypeId);

    /**
     * 获取方法分页列表
     *
     * @param pa
     * @return
     */
    PageVo<MethodListVo> getMethodList(MethodListPa pa);

    /**
     * 成员方法统计对比列表
     *
     * @param labId
     * @param firstTypeIds
     * @return
     */
    List<MethodContrastVo> getMethodContrastChartList(Long labId, List<Long> firstTypeIds);
    /**
     * 成员方法统计对比详情
     *
     * @param labId
     * @param 
     * @param sort 调用次数排序：0-升序，1-降序
     * @param sortType: 1-调用次（默认）,2-成功率,3-成员
     * @return
     */
    MethodContrastChartListVo getMethodContrastChart(Long labId, Long firstTypeId, String secondTypeName,
			String methodTypeName,Integer sortType, Integer sort);
    /**
     * 方法库成员列表
     *
     * @param labId
     * @param state 状态:1-正常，2-移出,null-全部
     * @return
     */
    List<MethodMemberVo> getMethodMemberList(Long userId,Long labId, Integer state);

    /**
     * ######################## WuMenghao #############################
     */
    List<Method> selectListByMethodTypeId(Long typeId,Long userId);

	boolean updateById(Method method);


    List<Method> selectListByIds(List<Long> methodIds);

    List<Method> listByRecommendMethodId(Long recommendMethodId);

    PageVo<Method> getPublicMethodList(Boolean isOnStock,String namePrefix,Integer pageSize,Integer pageNum);

	int getMethodCountByUserId(Long id);

    int getMethodCountByUserIdList(List<Long> ids);

    List<Method> selectCurrentListByMethodTypeIdsAndUserId(List<Long> thirdMethodTypeIds,Long userId,boolean hasCommonMethod);

    int countCurrentListByMethodTypeIdsAndUserId(List<Long> methodTypeIds,Long userId,boolean hasCommonMethod);

    boolean resetToCurrent(Long userId,Long initMehtodId);

    List<Method> insertBatch(List<Method> methods);

    int updateInitInfo(List<Method> methods);
}
